package com.huang.core.util

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.util.Base64
import android.widget.ImageView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.huang.core.provider.AppProvider
import java.io.ByteArrayOutputStream
import java.io.IOException

/**
 * Created by Android on 2018/8/31.
 */

object ImageUtil {

    /** 获取渲染了颜色的图标  */
    fun getTintDrawable(resId: Int, @ColorInt color: Int): Drawable {
        var drawable = ContextCompat.getDrawable(AppProvider.getInstance(), resId)!!
        drawable = DrawableCompat.wrap(drawable)
        DrawableCompat.setTint(drawable.mutate(), color)
        return drawable
    }

    /** 渲染图标颜色  */
    fun tint(resId: Int, @ColorInt color: Int, imageView: ImageView) {
        imageView.setImageDrawable(getTintDrawable(resId, color))
    }

}
